a11y: Add binding-friendly accessible property setter
authorEmmanuele Bassi <ebassi@gnome.org>
Mon, 13 Jul 2020 16:47:36 +0000 (17:47 +0100)
committerEmmanuele Bassi <ebassi@gnome.org>
Sun, 26 Jul 2020 19:31:15 +0000 (20:31 +0100)
Matching the one for the accessible state.

gtk/gtkaccessible.c
gtk/gtkaccessible.h

index 0d6e2bd717b7882bc6e3747e3f91a783258f435f..c06612ba837cbf48faf4c32fb14c0c1161423573 100644 (file)
@@ -239,3 +239,40 @@ gtk_accessible_update_property (GtkAccessible         *self,
 out:
   va_end (args);
 }
+
+/**
+ * gtk_accessible_update_property_value:
+ * @self: a #GtkAccessible
+ * @property: a #GtkAccessibleProperty
+ * @value: a #GValue with the value for @property
+ *
+ * Updates an accessible property.
+ *
+ * This function should be called by #GtkWidget types whenever an accessible
+ * property change must be communicated to assistive technologies.
+ *
+ * This function is meant to be used by language bindings.
+ */
+void
+gtk_accessible_update_property_value (GtkAccessible         *self,
+                                      GtkAccessibleProperty  property,
+                                      const GValue          *value)
+{
+  GtkATContext *context;
+
+  g_return_if_fail (GTK_IS_ACCESSIBLE (self));
+
+  context = gtk_accessible_get_at_context (self);
+  if (context == NULL)
+    return;
+
+  GtkAccessibleValue *real_value =
+    gtk_accessible_value_collect_for_property_value (property, value);
+
+  if (real_value == NULL)
+    return;
+
+  gtk_at_context_set_accessible_property (context, property, real_value);
+  gtk_accessible_value_unref (real_value);
+  gtk_at_context_update (context);
+}
index f95ba930d22c2844c5ce4f91761a957294d9f75e..9ad56784c7b9326bc580ba74719654bd3fb33b5c 100644 (file)
@@ -46,5 +46,9 @@ GDK_AVAILABLE_IN_ALL
 void                    gtk_accessible_update_state_value       (GtkAccessible         *self,
                                                                  GtkAccessibleState     state,
                                                                  const GValue          *value);
+GDK_AVAILABLE_IN_ALL
+void                    gtk_accessible_update_property_value    (GtkAccessible         *self,
+                                                                 GtkAccessibleProperty  property,
+                                                                 const GValue          *value);
 
 G_END_DECLS